<?php
/**
 * AdminPermissionDao
 *
 * @author fusq
 */

require_once BaseUtil::getModulePath("base") . '/models/BaseDao.php';
class AdminPermissionDao extends BaseDao {

    protected $_name;

    public function  _setup() {
        $this->_name = $this->prefix() . "admin_permissions";
        parent::_setup();
    }

    public function updateAdminPermission($adminPermission,$id){
        $where = $this->db_w->quoteInto('admin_id = ?', $id);
	    $this->updateData($adminPermission,$where);
    }

    public function getPermissionsByAdmin($adminId){
        $select = $this->db_r->select();
        $select->from($this->_name,"permission_key");
        $select->where('admin_id = ?', $adminId);
        $select->where('is_delete = 0');
        $sql = $select->__toString();
        $result = $this->db_r->fetchAll($sql);
        return $result;
    }

    public function deleteAdminPermission($adminId){
        $where = $this->db_w->quoteInto('admin_id = ?', $adminId);
        $this->delete($where);
    }
}
